﻿namespace Resharper.Abstractions.CodeDom.Types
{
  using System;
  using JetBrains.Annotations;
  using JetBrains.ReSharper.Psi.CSharp.Tree;
  using JetBrains.ReSharper.Psi.Tree;
  using Resharper.Abstractions.CodeDom.Expressions;
  using Resharper.Abstractions.CodeDom.Types.Classes;

  /// <summary>Defines the <see cref="ExpressionFactory"/> class.</summary>
  internal static class TypeFactory
  {
    #region Public Methods

    /// <summary>Gets the expression.</summary>
    /// <param name="type">The type member.</param>
    /// <returns>Returns the expression.</returns>
    [NotNull]
    public static TypeElement GetTypeMember([NotNull] ITypeDeclaration type)
    {
      if (type == null)
      {
        throw new ArgumentNullException("type");
      }

      if (type is IClassDeclaration)
      {
        return new Class((IClassDeclaration)type);
      }

      return new TypeElement(type);
    }

    #endregion
  }
}